import lombok.Data;

@Data
public class Host {
    private String host;
    private int port;
    private String user;

    public Host(String str) {
        if (str.contains("@")) {
            String[] arr = str.split("@");
            this.user = arr[0];
            str = arr[1];
        }
        String[] arr = str.split(":");
        this.host = arr[0];
        this.port = Integer.parseInt(arr[1]);
    }

    @Override
    public String toString() {
        return (this.user == null ? "" : this.user + "@") + this.host + ":" + this.port;
    }
}
